package org.tloss.web.editor.message.editors;

import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;

public class FieldProperties implements IPropertySource {
	final protected FieldElement element;
	

	protected void firePropertyChanged(String propName, Object value) {
		IResourceChangeListener listener = element.getListener();
		if (listener != null)
			listener.resourceChanged(null);
		element.firePropertyChanged(propName, value);
	}

	/**
	 * Creates a new ButtonElementProperties.
	 * 
	 * @param element
	 *            the element whose properties this instance represents
	 */
	public FieldProperties(FieldElement element) {
		super();
		this.element = element;
	}

	/**
	 * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
	 */
	public Object getEditableValue() {
		return this;
	}

	/**
	 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
	 */
	public IPropertyDescriptor[] getPropertyDescriptors() {
		return element.getPropertyDescriptors();

	}

	/**
	 * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(Object)
	 */
	public Object getPropertyValue(Object name) {
		return element.getProperty((String) name);
	}

	/**
	 * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(Object)
	 */
	public boolean isPropertySet(Object id) {
		return false;
	}

	/**
	 * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(Object)
	 */
	public void resetPropertyValue(Object id) {
	}

	/**
	 * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(Object,
	 *      Object)
	 */
	public void setPropertyValue(Object name, Object value) {
		firePropertyChanged((String) name, value);

	}

}
